package com.wondertek.poms.dao.po;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Data;

/**
 * <p><b>EquityNode Description:</b> 权益节点</p>
 * @author douzi
 * <b>DATE</b> 2020年11月18日 下午5:12:19
 */
@Data
@Entity
@Table(name = "EQUITY_NODE")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class EquityNode implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "EQUITY_NODE_SEQ")
	@SequenceGenerator(name = "EQUITY_NODE_SEQ", allocationSize = 1, sequenceName = "EQUITY_NODE_SEQ")
	private Long id;// 权益节点id

	@Column(name = "TREE_ID")
	private Long treeId; // 权益树id 对应EquityTree的id
	
	@Column(name = "NAME")
	private String name;// 权益节点名

	@Column(name = "EQUITY_Node_ID")
	private String equityNodeId;// 权益节点编码
	
	@Column(name = "GROUP_ID")
	private Long groupId; // 关联组id
	
	@Column(name = "PARENT_ID")
	private Long parentId;// 父权益节点 第一级的父权益节点 0
	
	@Column(name = "NODE_ALIAS")
	private String nodeAlias;// 节点别名
	
	@Column(name = "STATUS")
	private String status; // 0 启用 1：禁用
	
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "CREATE_TIME")
	private Date createTime;
	
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "UPDATE_TIME")
	private Date updateTime;
	
	@Column(name = "HIERARCHY")
	private Integer hierarchy; // 层级

	@Column(name = "SAVE_STATUS")
	private Integer saveStatus; // 保存状态 0：以保存 1：待保存
	
	@Column(name = "DELETE_STATUS")
	private Integer deleteStatus = 0;  // 0:未删除   1：已删除
	
	public static void putTimeAndUser(EquityNode equityNode) {
		if (equityNode.id == null) {
			equityNode.setCreateTime(new Date());
		}
		equityNode.setUpdateTime(new Date());
	}
}
